import java.util.Arrays;

/**
 * @author luoqingbo
 * @create 2024/4/28 14:58
 */
public class Leetcode2639 {
    public static void main(String[] args) {
//        输入：grid = [[1],[22],[333]]
//        输出：[3]
//        解释：第 0 列中，333 字符串长度为 3
        int[][] grid = new int[][]{{1}, {22}, {333}};
        System.out.println(Arrays.toString(findColumnWidth(grid)));
        int[][] grid1 = new int[][]{{-15, 1, 3}, {15, 7, 12}, {5, 6, -1}};
        System.out.println(Arrays.toString(findColumnWidth(grid1)));

    }

    public static int[] findColumnWidth(int[][] grid) {
        int[] res = new int[grid[0].length];
        for (int i = 0; i < grid.length; i++) {
            for (int j = 0; j < grid[i].length; j++) {
                int len = String.valueOf(grid[i][j]).length();
                res[j] = Math.max(res[j], len);
            }
        }
        return res;
    }
}
